﻿#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

//18.求字符串⻓度【进阶版】
int Strlen(char* arr)
{
	if (*arr == '\n')
	{
		return 0;
	}
	else
	{
		return 1 + Strlen(arr + 1);
	}
}
int main()
{
	char arr[31] = { 0 };
	scanf("%s", arr);
	int len = Strlen(arr + 1);
	printf("%d", len);
	return 0;
}


//19. 逆序字符串
#include <string.h>

void reverse(char* arr)
{
	int len = strlen(arr);
	char* left = arr;
	char* right = arr + len - 1;
	while (left < right)
	{
		char tmp = *left;
		*left = *right;
		*right = tmp;
		left++;
		right--;
	}
}
int main()
{
	char arr[31] = { 0 };
	scanf("%s", arr);
	reverse(arr);
	printf("%s", arr);
	return 0;
}


//20.求数字的每⼀位之和
int main()
{
	int m = 0;
	scanf("%d", &m);
	int sum = 0;
	while (m > 0)
	{
		sum += m % 10;
		m /= 10;
	}
	printf("%d", sum);
	return 0;
}


//21.判断回⽂字符串
#include <string.h>
int estimate(char* arr)
{
	int len = strlen(arr);
	char* left = arr;
	char* right = arr + len - 1;
	while (left < right)
	{
		if (*left != *right)
		{
			return 0;
		}
		left++;
		right--;
	}
	return 1;
}
int main()
{
	char arr[31] = { 0 };
	int ret = estimate(arr);
	if (ret == 0)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
	return 0;
}


//22.计算天数
int day(int y, int m)
{
	int leap = 0;
	if ((y % 4 == 0 && y % 100 != 0) || (y % 400 == 0))
	{
		leap = 1;
	}
	int day[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	if (leap == 1)
	{
		day[2] = 29;
	}
	return day[m];
}
int main()
{
	int y = 0, m = 0;
	scanf("%d %d", &y, &m);
	int ret = day(y, m);
	printf("%d", ret);
	return 0;
}


//23.删除指定的数
int main()
{
	int arr[10] = { 0 };
	int n = 0;
	int i = 0;
	//输入
	for (i = 0; i < 10; i++)  
	{
		scanf("%d", &arr[i]);
	}
	scanf("%d", &n);         

	//删除
	int j = 0;               
	for (i = 0; i < 10; i++)
	{
		//若当前数与给定值不相同，不需要删除，将其填⼊第j个位置，将j后移
		if (arr[i] != n)
		{
			arr[j++] = arr[i];
		}
	}
	//打印
	for (i = 0; i < j; i++)
	{
		printf("%d ", arr[i]);
	}
	return 0;
}


//24.字符串拷⻉
void my_strcpy(char* a, char* b)
{

	while (*a != '\0')
	{
		*b = *a;
		a++;
		b++;
	}
	*b = '\0';
}
int main()
{
	char a[] = "wwwwwwwwww";
	char b[20] = { 0 };
	my_strcpy(a, b);
	printf("%s", b);
	return 0;
}

